<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let map = new Map()
    let id = 'id'
    map.set(id, '字符串')
    let a = map.get('id')
    let b = map.get(id)
    console.log(a);
    console.log(b);
    // console.log(map);

    let funid = function () { }
    map.set(funid, '函数')
    let funa = map.get(funid)
    console.log(funa);
    // console.log(map);

    let objid = {}
    map.set(objid, '对象')
    let obja = map.get(objid)
    console.log(obja);
    console.log(map);


    //删除
    map.delete('id')
    //清空
    // map.clear()
    //查看是否含有
    console.log(map.has(funid));

    map.forEach(function (value, key) {
      console.log(key, value);
      console.log(typeof key);
      console.log(typeof value);
    })
    // for (var obj of map) {
    //   console.log(obj[0], obj[1]);
    // }
    // for (let [key, value] of map) {
    //   console.log(key, value);
    // }
    console.log('===========');
    console.log(typeof map);

    console.log('===========');
    //遍历
    let iterator1 = map.keys()//获取所有键的集合
    let value
    while (value = iterator1.next().value) {
      console.log(value);
    }

    console.log('++++++++');
    let [...arr] = map.entries()//map转数组
    console.log(arr);

    let map1 = new Map(arr)//数组转map
    console.log(map1);

    var obj = {
      name: '小好',
      age: 18
    };
    var tempArr = Object.entries(obj);//对象转数组
    console.log(tempArr);

  </script>
</body>

</html>